/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class ctrl_AmendmentActivities_Test {

    static testMethod void myUnitTest()
    {
        // TO DO: implement unit test
        
        
         //Account Object Record...
        Account accountObject = new Account();
        accountObject.Name = 'Test Account';
        //accountObject.LicenseNumber__c = serialObject.id;
        accountObject.License_Application_Step__c = 'Record Created';
        accountObject.License_Application_Type__c = 'New License';
        accountObject.Activity__c = 'Trading - Three Activity';
        accountObject.License_Issue_Date__c = system.today();
        accountObject.License_Expiry_Date__c = System.Today().addYears(1);
        insert accountObject;
        
        //Sub Activity Object Record...
        Sub_Activity__c subActivityObject = new Sub_Activity__c();
        subActivityObject.Activity_Type__c = 'Commercial';
        subActivityObject.Name = 'Test Activity';
        insert subActivityObject;
        
        //Sub Activity Object Record...
        Sub_Activity__c subActivityObject1 = new Sub_Activity__c();
        subActivityObject1.Activity_Type__c = 'Commercial';
        subActivityObject1.Name = 'Test Activity1';
        insert subActivityObject1;
        
        //For Account Activity Object Records FOR EDIT...
        Account_Activity__c accountActivityObject = new Account_Activity__c();
        accountActivityObject.Account__c = accountObject.Id;
        accountActivityObject.Activity__c = subActivityObject.Id; 
        accountActivityObject.Active__c = true;
        insert accountActivityObject;
        
         //For Account Activity Object Records FOR DELETE...
        Account_Activity__c accountActivityObject1 = new Account_Activity__c();
        accountActivityObject1.Account__c = accountObject.Id;
        accountActivityObject1.Activity__c = subActivityObject.Id; 
        accountActivityObject1.Active__c = true;
        insert accountActivityObject1;
        
        
        //For Amendment Record Type...//For Updating the Authorized Manager...
        
        //Map<string,RecordType> amendmentRecordTypeMap = new Map<string,RecordType>([SELECT Id,SObjectType,DeveloperName,IsActive FROM RecordType where SObjectType =: 'Amendment__c' And DeveloperName IN('Company_Amendment_Change_Company_Name','Company_Amendment_Change_License_Type','Shareholder_Amendment_Add_Partner')]);
        Map<string,RecordType> amendmentRecordTypeMap = new Map<string,RecordType>();
        for(RecordType tempObject : [SELECT Id,SObjectType,DeveloperName,IsActive FROM RecordType where SObjectType =: 'Amendment__c' And DeveloperName IN('Company_Amendment_Change_Company_Name','Company_Amendment_Change_License_Type','Shareholder_Amendment_Add_Partner','Company_Amendment_Change_Company_Manager','Company_Amendment_Change_Company_Activity')])
        {
            amendmentRecordTypeMap.put(tempObject.DeveloperName, tempObject);
            
        }
        
        //For Amendment Object For Company License Type...
        Amendment__c amendmentObject1 = new Amendment__c();
        amendmentObject1.RecordTypeId = amendmentRecordTypeMap.get('Company_Amendment_Change_License_Type').Id;
        amendmentObject1.Account__c = accountObject.Id;
        amendmentObject1.New_Company_Name__c = 'Test New Name';
        amendmentObject1.New_Company_Name_Arabic__c = 'test New Name Arabic';
        amendmentObject1.Previous_License_Type__c = accountObject.Activity__c;
        amendmentObject1.New_License_Type__c = accountObject.Activity__c; 
        insert amendmentObject1;
        
        
        //For Amendment Activity Object... Add Flag...
        Amendment_Activity__c amendemntActivityObject = new Amendment_Activity__c();
        amendemntActivityObject.Account__c = accountObject.Id;
        amendemntActivityObject.Active__c = true;
        amendemntActivityObject.Activity__c = subActivityObject.id;
        amendemntActivityObject.Add_Flag__c  = true;
        amendemntActivityObject.Amendment__c = amendmentObject1.Id;
        insert amendemntActivityObject; 
        
        //For Edit Flag...        
        Amendment_Activity__c amendemntActivityObject1 = new Amendment_Activity__c();
        amendemntActivityObject1.Account__c = accountObject.Id;
        amendemntActivityObject1.Active__c = true;
        amendemntActivityObject1.Activity__c = subActivityObject1.id;
        amendemntActivityObject1.Account_Activity__c = accountActivityObject.Id;
        amendemntActivityObject1.Edit_Flag__c  = true;
        amendemntActivityObject1.Amendment__c = amendmentObject1.Id;
        insert amendemntActivityObject1;
        
        //For Delete Flag...
        Amendment_Activity__c amendemntActivityObject2 = new Amendment_Activity__c();
        amendemntActivityObject2.Account__c = accountObject.Id;
        amendemntActivityObject2.Active__c = true;
        amendemntActivityObject2.Activity__c = subActivityObject1.id;
        amendemntActivityObject2.Delete_Flag__c  = true;
        amendemntActivityObject2.Account_Activity__c = accountActivityObject1.Id;
        amendemntActivityObject2.Amendment__c = amendmentObject1.Id;
        insert amendemntActivityObject2;
           
        
        //Amendment Id Standard Controller...
        ApexPages.StandardController amendmentExtendedObject = new ApexPages.StandardController(amendmentObject1);
        ApexPages.CurrentPage().getParameters().put('id',amendmentObject1.id);
        
        ctrl_AmendmentActivities amendmentActivityClass = new ctrl_AmendmentActivities(amendmentExtendedObject);
        
        amendmentActivityClass.generatePaymentModule();
        amendmentActivityClass.additems();
        amendmentActivityClass.RowIndex = 'j_id0:MainForm:j_id50:0:j_id52:0:EDITID';
        
        //amendmentActivityClass.ReceiptWrapper  wrapperClass = new amendmentActivityClass.ReceiptWrapper(amendmentObject.Name,'Company_Amendment_Change_License_Type', 2, amendmentObject.id);
        amendmentActivityClass.EditAllow();
        amendmentActivityClass.updateitemlist();
        amendmentActivityClass.cancelEdit();
        amendmentActivityClass.RowIndex = 'j_id0:MainForm:j_id50:0:j_id52:0:EDITID';
        amendmentActivityClass.DelAllow();
        
        
        
        
    }
}